<template>
	<view :style="$theme.pageStyle">
		<view class="px-32">
			<view class="fs-36 fw-500 lh-54rpx mt-44">{{ articleInfo.title }}</view>
			<view class="flex fs-24 text--w111-999 mt-16">
				<text>{{ articleInfo.catename }}</text>
				<text class="px-16">|</text>
				<text>{{ articleInfo.create_time }}</text>
			</view>
			<view class="content fs-30 text--w111-333 lh-52rpx mt-32">
				<u-parse :content="content"></u-parse>
			</view>
			<!-- <view class="bg--w111-f5f5f5 rd-24rpx w-full flex-between-center p-20 mt-32" @tap="goDetail"
				v-if="store_info.id">
				<image :src="store_info.image" class="w-160 h-160 rd-16rpx" mode="aspectFill"></image>
				<view class="flex-1 h-160 flex-col justify-between pl-20">
					<view class="w-full fs-28 lh-40rpx line2">{{ store_info.store_name }}</view>
					<view class="flex justify-between items-end">
						<baseMoney :money="store_info.price" symbolSize="28" integerSize="44" decimalSize="28" weight>
						</baseMoney>
						<view class="w-136 h-52 rd-30rpx flex-center fs-22 text--w111-fff bg-gradient">立即购买</view>
					</view>
				</view>
			</view> -->
		</view>
		<view class="h-200"></view>
		<view class="bg--w111-fff w-full z-99 fixed-lb pb-safe">
			<view class="w-full h-128 pr-20 flex-y-center" v-if="store_info.id">
				<button open-type="share" hover-class="none">
					<text class="iconfont icon-ic_transmit1 fs-44 ml-52"></text>
				</button>
				<view class="ml-80 relative">
					<uni-icons type="undo" size="30"></uni-icons>
					<text class="fs-20 fw-500 abs-num">{{ articleInfo.click }}</text>
				</view>
				<view class="ml-80 relative" :class="{ active: articleInfo.is_like }" @tap="giveLike">
					<uni-icons type="eye" size="30"></uni-icons>
					<text class="fs-20 fw-500 likes-num">{{ articleInfo.likes }}</text>
				</view>
				<view class="w-300 h-72 rd-36rpx flex-center bg--w111-f5f5f5 ml-80" @tap="goDetail">
					<image :src="store_info.image" class="w-48 h-48 rd-8rpx"></image>
					<view class="pl-12">
						<view class="fs-22 fw-500 w-172 line1">{{ store_info.store_name }}</view>
						<view class="fs-20 SemiBold">¥{{ store_info.price }}</view>
					</view>
				</view>
			</view>
			<view class="w-full px-120 h-128 flex-between-center" v-else>
				<button open-type="share" hover-class="none">
					<uni-icons type="undo" size="30"></uni-icons>
				</button>
				<view class="relative">
					<uni-icons type="eye" size="30"></uni-icons>
					<text class="fs-20 fw-500 abs-num">{{ articleInfo.click }}</text>
				</view>
				<view class="relative" :class="{ active: articleInfo.is_like }" @tap="giveLike">
					<uni-icons type="hand-up" size="30"></uni-icons>
					<text class="fs-20 fw-500 likes-num">{{ articleInfo.likes }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import $H from '@/common/js/request.js';
	export default {
		components: {
		},
		data() {
			return {
				id: 0,
				articleInfo: [],
				store_info: {},
				content: '',
				shareInfoStatus: false,
				tagStyle: {
					img: 'width:100%;display:block;border-radius:8px;',
					table: 'width:100%',
					video: 'width:100%'
				}
			};
		},
		onLoad: function(options) {
			if (options.hasOwnProperty('id')) {
				this.id = options.id;
			} else {
				// #ifndef H5
				uni.navigateBack({
					delta: 1
				});
				// #endif
			}
		},
		onShow: function() {
			this.getArticleOne();
		},
		methods: {
			
			async getArticleOne() {
				try {
					const res = await $H.get('article/detail', {
						id : this.id
					}, {
						token: false
					});
					uni.setNavigationBarTitle({
						title: res.data.title.substring(0, 7) + '...'
					});
					
					this.content = res.data.content;
					this.articleInfo = res.data;
					
				} catch (error) {
			
				} finally {
			
				}
			},
			// giveLike() {
			// 	if (!this.isLogin) {
			// 		toLogin();
			// 	} else {
			// 		articleStarApi(this.id, {
			// 			status: this.articleInfo.is_like ? 0 : 1
			// 		}).then((res) => {
			// 			let that = this;
			// 			uni.showToast({
			// 				title: this.articleInfo.is_like ? '取消点赞' : '点赞成功',
			// 				icon: 'none',
			// 				success: () => {
			// 					if (this.articleInfo.is_like) {
			// 						that.articleInfo.likes = that.articleInfo.likes - 1;
			// 						that.articleInfo.is_like = 0;
			// 					} else {
			// 						that.articleInfo.likes = that.articleInfo.likes + 1;
			// 						that.articleInfo.is_like = 1;
			// 					}
			// 				}
			// 			});
			// 		});
			// 	}
			// },
			
		}
	};
</script>
<style>
	page {
		background-color: #ffffff;
	}
</style>
<style lang="scss">
	.active {
		color: var(--view-theme);
	}

	.content {
		text-indent: 2em;
	}

	.ml-52 {
		margin-left: 52rpx;
	}

	.ml-80 {
		margin-left: 80rpx;
	}

	.abs-num {
		position: absolute;
		right: -26rpx;
		top: -10rpx;
	}

	.likes-num {
		position: absolute;
		right: -16rpx;
		top: -10rpx;
	}

	.SemiBold {
		font-family: 'SemiBold';
	}
	
	button {
		border: 0;
		background-color: transparent;
		outline: none;
		line-height: normal;
		margin: 0;
		padding: 0;
	}
	
	button::after {
		border: none;
		width: 0;
		height: 0;
	}
	
</style>